<%@ page import="bugtracking.Bug" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'bug.label', default: 'Bug')}"/>
    <title><g:message code="default.edit.label" args="[entityName]"/></title>
</head>

<body>
<div class="nav">
    <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a>
    </span>
    <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label"
                                                                           args="[entityName]"/></g:link></span>
    <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label"
                                                                               args="[entityName]"/></g:link></span>
</div>

<div class="body">
    <h1><g:message code="default.edit.label" args="[entityName]"/></h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${bugInstance}">
        <div class="errors">
            <g:renderErrors bean="${bugInstance}" as="list"/>
        </div>
    </g:hasErrors>
    <g:form method="post">
        <g:hiddenField name="id" value="${bugInstance?.id}"/>
        <g:hiddenField name="version" value="${bugInstance?.version}"/>
        <div class="dialog">
            <table>
                <tbody>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="assigned_to"><g:message code="bug.assigned_to.label" default="Assignedto"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'assigned_to', 'errors')}">
                        <g:select name="assigned_to.id" from="${bugtracking.Actor.list()}" optionKey="id"
                                  value="${bugInstance?.assigned_to?.id}" noSelection="['null': '']"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="reporter"><g:message code="bug.reporter.label" default="Reporter"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'reporter', 'errors')}">
                        <g:select name="reporter.id" from="${bugtracking.Actor.list()}" optionKey="id"
                                  value="${bugInstance?.reporter?.id}" noSelection="['null': '']"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="qa_contact"><g:message code="bug.qa_contact.label" default="Qacontact"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'qa_contact', 'errors')}">
                        <g:select name="qa_contact.id" from="${bugtracking.Actor.list()}" optionKey="id"
                                  value="${bugInstance?.qa_contact?.id}" noSelection="['null': '']"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="bug_id"><g:message code="bug.bug_id.label" default="Bugid"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'bug_id', 'errors')}">
                        <g:textField name="bug_id" value="${fieldValue(bean: bugInstance, field: 'bug_id')}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="bug_status"><g:message code="bug.bug_status.label" default="Bugstatus"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'bug_status', 'errors')}">
                        <g:textField name="bug_status" value="${bugInstance?.bug_status}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="bug_version"><g:message code="bug.bug_version.label" default="Bugversion"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'bug_version', 'errors')}">
                        <g:textField name="bug_version" value="${bugInstance?.bug_version}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="component"><g:message code="bug.component.label" default="Component"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'component', 'errors')}">
                        <g:textField name="component" value="${bugInstance?.component}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="creation_ts"><g:message code="bug.creation_ts.label" default="Creationts"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'creation_ts', 'errors')}">
                        <g:datePicker name="creation_ts" precision="day" value="${bugInstance?.creation_ts}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="delta_ts"><g:message code="bug.delta_ts.label" default="Deltats"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'delta_ts', 'errors')}">
                        <g:datePicker name="delta_ts" precision="day" value="${bugInstance?.delta_ts}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="history"><g:message code="bug.history.label" default="History"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'history', 'errors')}">

                        <ul>
                            <g:each in="${bugInstance?.history?}" var="h">
                                <li><g:link controller="history" action="show"
                                            id="${h.id}">${h?.encodeAsHTML()}</g:link></li>
                            </g:each>
                        </ul>
                        <g:link controller="history" action="create"
                                params="['bug.id': bugInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'history.label', default: 'History')])}</g:link>

                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="op_sys"><g:message code="bug.op_sys.label" default="Opsys"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'op_sys', 'errors')}">
                        <g:textField name="op_sys" value="${bugInstance?.op_sys}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="priority"><g:message code="bug.priority.label" default="Priority"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'priority', 'errors')}">
                        <g:textField name="priority" value="${bugInstance?.priority}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="product"><g:message code="bug.product.label" default="Product"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'product', 'errors')}">
                        <g:textField name="product" value="${bugInstance?.product}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="rep_platform"><g:message code="bug.rep_platform.label"
                                                             default="Repplatform"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'rep_platform', 'errors')}">
                        <g:textField name="rep_platform" value="${bugInstance?.rep_platform}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="resolution"><g:message code="bug.resolution.label" default="Resolution"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'resolution', 'errors')}">
                        <g:textField name="resolution" value="${bugInstance?.resolution}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="severity"><g:message code="bug.severity.label" default="Severity"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'severity', 'errors')}">
                        <g:textField name="severity" value="${bugInstance?.severity}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="short_desc"><g:message code="bug.short_desc.label" default="Shortdesc"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'short_desc', 'errors')}">
                        <g:textField name="short_desc" value="${bugInstance?.short_desc}"/>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="target_milestone"><g:message code="bug.target_milestone.label"
                                                                 default="Targetmilestone"/></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: bugInstance, field: 'target_milestone', 'errors')}">
                        <g:textField name="target_milestone" value="${bugInstance?.target_milestone}"/>
                    </td>
                </tr>

                </tbody>
            </table>
        </div>

        <div class="buttons">
            <span class="button"><g:actionSubmit class="save" action="update"
                                                 value="${message(code: 'default.button.update.label', default: 'Update')}"/></span>
            <span class="button"><g:actionSubmit class="delete" action="delete"
                                                 value="${message(code: 'default.button.delete.label', default: 'Delete')}"
                                                 onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"/></span>
        </div>
    </g:form>
</div>
</body>
</html>
